package com.niit.controller.example;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class RenameTable {

    private static String driverClass = "org.apache.hive.jdbc.HiveDriver";
    public static void main(String[] args) throws SQLException {

        try {
            Class.forName(driverClass);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Connection connection = DriverManager.getConnection("jdbc:hive2://niit-china:10000/default","root","singh321");
        Statement statement = connection.createStatement();
        String old_table_name ="Customer";
        String new_table_name ="MyCustomer";
        String query1 = "Alter table "+old_table_name+" rename to "+new_table_name;
        try {
            statement.execute(query1);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

        System.out.println("Table name has changed successfully");
        statement.close();
        connection.close();

    }
}
